import type { Cart as CartType } from "@/type/CartType";
import { useEnhanceSelector } from "@/hooks/index";
import {  useMemo } from "react";

const useCartTotal = () => {
   const cartList: CartType[] = useEnhanceSelector(state => state.cartStore.cartList);
   const checkedList: number = useMemo(() => cartList.filter(item => item.checked).reduce((sum, item) => sum += item.goods_num, 0), [cartList]);
   return checkedList
};

export default useCartTotal;
